/**
 * @file ngmessagecoder.h
 * @author Suk Robert Koh (srkoh87z@gmail.com)
 *
 * @brief NGMessageCoder class is an abstract class to be extended by message coders
 */

#ifndef NGMESSAGECODER_H_
#define NGMESSAGECODER_H_

#include "ngmessage.h"
#include "../ngtypes.h"

/**
 * @class	NGMessageCoder	Abstract class for message coder classes
 */
class NGMessageCoder
{
public:
	NGMessageCoder(BYTE _frontCode, BYTE _endCode, BYTE _headerSize, BYTE _trailerSize, BOOL _doEncryption);
	virtual ~NGMessageCoder();

	virtual char *encode(NGMessage *msg) = 0;
	virtual NGMessage *decode(const char *data, DWORD userId) = 0;

	virtual WORD getMessageLength(const char *header) = 0;
	BYTE getHeaderSize();
	BYTE getTrailerSize();

protected:
	BYTE frontCode;										/** Code which comes in the very beginning */
	BYTE endCode;										/** Code which comes at the very end */
	BYTE headerSize;									/** Size of the header */
	BYTE trailerSize;									/** Size of the trailer */
	BOOL doEncryption;									/** Whether to encrypt messages */
};

#endif /* NGMESSAGECODER_H_ */
